﻿
<script type="text/javascript">
    var roomidglobal = -1;
    var xmlhttp;
    function readyentry()
    {
        setInterval(ready, 1000);
    }
    function ready() {
        if (roomidglobal == -1) {
            readyentry();
        }
        roomidglobal=document.getElementById("roomid").innerHTML;
        

        xmlhttp = null;
        if (window.XMLHttpRequest) {// code for all new browsers
            xmlhttp = new XMLHttpRequest();
        }
        else if (window.ActiveXObject) {// code for IE5 and IE6
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        if (xmlhttp != null) {
            xmlhttp.onreadystatechange = state_Change;
            xmlhttp.open("GET", "http://localhost:9746/Question/Game3/?roomid=" + roomidglobal +
                "&uname="+document.getElementById("uname").innerHTML, true);
            xmlhttp.send();
        }
        else {
            alert("Your browser does not support XMLHTTP.");
        }
    }


    function state_Change() {
        if (xmlhttp.readyState == 4) {// 4 = "loaded"
            if (xmlhttp.status == 200) {// 200 = OK
                // ...our code here...
                if (xmlhttp.responseText == "yes") {
                    window.location = "http://localhost:9746/Question/Game/?uname=" + 
                        document.getElementById("uname").innerHTML+"&roomid="+roomidglobal;
                } 
            }
        }
    }
    
  //   @Html.ActionLink("准备", "Game", "Question", new { roomid = @ViewBag.roomid }, new {@id="ready"})
</script>

@{
    ViewBag.Title = "Room";
}
<div class="container">
<h2>Room</h2>
<p class="text-left">Room:</p>
<p class="text-left" id="roomid">@ViewBag.roomid</p>
<p class="text-left">用户名:</p>
<p class="text-left" id="uname">@ViewBag.name</p>
<table class = "table table-bordered table-hover table-striped table-condensed">
  <tr>
    <th scope="col"><p id="user1">User1</p>
    <p><img src="/i/eg_mouse.jpg" width="128" height="128" /></p></th>
    <th scope="col"><p id="user2">User2</p>
    <p><img src="/i/eg_mouse.jpg" width="128" height="128" /></p></th>
    <th scope="col"><p>User3</p>
    <p><img src="/i/eg_mouse.jpg" width="128" height="128" /></p></th>
    <th scope="col"><p>User4</p>
    <p><img src="/i/eg_mouse.jpg" width="128" height="128" /></p></th>
  </tr>
  <tr>
    <th scope="col"><p>User5</p>
    <p><img src="/i/eg_mouse.jpg" width="128" height="128" /></p></th>
	<th scope="col"><p>User6</p>
    <p><img src="/i/eg_mouse.jpg" width="128" height="128" /></p></th>
	<th scope="col"><p>User7</p>
    <p><img src="/i/eg_mouse.jpg" width="128" height="128" /></p></th>
	<th scope="col"><p>User8</p>
    <p><img src="/i/eg_mouse.jpg" width="128" height="128" /></p></th>
  </tr>
</table>
    <div class="btn-group">
        <button class="btn btn-primary" id="roomid1entry" onmousedown ="readyentry()">准备</button>
        @Html.ActionLink("退出", "Hall", new {userName = @ViewBag.name, need=true,roomid = @ViewBag.roomid },
             new { @class="btn btn-primary"})
    </div>
<p align="center">&nbsp;</p>
</div>